<template>
	<view>
		<view class="Jy_shopping-list-page">
			<view class="Jy_shop-head-option-group">
				<!-- 头部导航栏 -->
			</view>
			<view class="Jy_shop-group">
				<view class="Jy_collection_empty_group" v-if="isEmpty">
					<DataEmpty
						imageUrl="https://louiscloud-1304691295.cos.ap-guangzhou.myqcloud.com/home/%E6%9A%82%E6%97%A0%E6%95%B0%E6%8D%AE.png"
						startPadding="true" tipsText="暂无数据"></DataEmpty>
				</view>
				<view class="shop-list-container">
					<view class="shop-list" v-for="(item, index) in productList" :key="index"
						@click="getShoppingDetail(item)">
						<view class="shop-image-box">
							<image :src="item.image" mode="widthFix"></image>
						</view>
						<view class="shop-name-box">
							<text>{{item.storeName}}</text>
						</view>
						<view class="price-space-box">
							<text>￥{{item.price}}</text>
							<!-- <text>-</text> -->
							<!-- <text>￥3999</text> -->
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	// 数据为空
	import DataEmpty from '../../../../components/DataEmpty.vue';

	export default {
		components: {
			DataEmpty
		},
		data() {
			return {
				cid: '',
				productList: [],
				isEmpty: true,

			};
		},
		onLoad(option) {
			this.cid = option.cid
			this.getProductList();
		},
		methods: {

			getProductList() {
				let data = {
					news: 0,
					page: 1,
					limit: 20,
					cid: this.cid,
				}
				// 获取商品
				this.sendRequest({
					url: "/api/front/products",
					data: data,
					success: res => {
						if (res.data.data.list.length > 0) {
							this.isEmpty = false
							this.productList = this.productList.concat(res.data.data.list);
						}
					}
				})
			},

			// 跳转到商品详情
			getShoppingDetail(item) {
				uni.navigateTo({
					url: '/pages/shoppingDetail/shoppingDetail?productId='+item.id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import 'shoppingList.scss';
</style>
